package com.debao.system.service.impl;

import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.debao.system.mapper.CoachMapper;
import com.debao.system.domain.Coach;
import com.debao.system.service.ICoachService;

/**
 * 教练Service业务层处理
 * 
 * @author ruoyi
 * @date 2024-05-15
 */
@Service
public class CoachServiceImpl implements ICoachService 
{
    @Autowired
    private CoachMapper coachMapper;

    /**
     * 查询教练
     * 
     * @param id 教练主键
     * @return 教练
     */
    @Override
    public Coach selectCoachById(Long id)
    {
        coachMapper.updHot(id);
        return coachMapper.selectCoachById(id);
    }


    /**
     * 根据用户id查询教练
     * @param userId
     * @return
     */
    public Coach selectCoachByUserId(Long userId){
        return coachMapper.selectCoachByUserId(userId);
    }

    /**
     * 查询教练列表
     * 
     * @param coach 教练
     * @return 教练
     */
    @Override
    public List<Coach> selectCoachList(Coach coach)
    {
        return coachMapper.selectCoachList(coach);
    }

    /**
     * 新增教练
     * 
     * @param coach 教练
     * @return 结果
     */
    @Override
    public int insertCoach(Coach coach)
    {
        return coachMapper.insertCoach(coach);
    }

    /**
     * 批量更新教练
     * @param coaches
     */

    @Override
    public void updateCoachesInBatch(List<Coach> coaches) {
        // 批量更新教练信息
        coachMapper.updateCoachesInBatch(coaches);
    }

    /**
     * 修改教练
     * 
     * @param coach 教练
     * @return 结果
     */
    @Override
    public int updateCoach(Coach coach)
    {
        return coachMapper.updateCoach(coach);
    }

    /**
     * 更新教练粉丝数
     * @param userId
     * @param type
     */
    @Override
    public void updateUploadFans(Long userId, String type) {
        coachMapper.updateUploadFans(userId, type);
    }


    /**
     * 批量删除教练
     * 
     * @param ids 需要删除的教练主键
     * @return 结果
     */
    @Override
    public int deleteCoachByIds(Long[] ids)
    {
        return coachMapper.deleteCoachByIds(ids);
    }

    /**
     * 删除教练信息
     * 
     * @param id 教练主键
     * @return 结果
     */
    @Override
    public int deleteCoachById(Long id)
    {
        return coachMapper.deleteCoachById(id);
    }

    @Override
    public int totalCount(String beforeDate){
        return coachMapper.totalCount(beforeDate);
    }
}
